<?php
$criteria = new CDbCriteria();
$criteria->order = 'sorter ASC';
$category = ProductCategory::model()->findAllByAttributes(array('status' => 1), $criteria);

if(isset($categoryId) && $categoryId) {
	$product = Product::model()->findAllByAttributes(array('status' => 1, 'product_category_id' => $categoryId));
} else {
	$product = Product::model()->findAllByAttributes(array('status' => 1));
}
?>
<div class="spotlight">
    <img src="<?php echo Yii::app()->theme->baseUrl ?>/images/cat/1.jpg" alt="Category Image" class="spl-thumb"/>
    <h2 class="spl-info small">Sản phẩm</h2>
</div><!-- /.spotlight -->
<section class="main-content container">
    <div class="cat-filter clearfix">
        <span class="ftr-clip"><i class="icon-list">&nbsp;</i></span>
        <ul class="ftr-list">
            <li><a href="javascript:void(0)" class="active">Tất cả</a></li>
            <?php if($category): foreach ($category as $c): ?>
            <li><a href="javascript:void(0)" data-oe-prdID="<?php echo $c->id ?>"><?php echo $c->title ?></a></li>
            <?php endforeach; endif; ?>
        </ul>
    </div>
    <div class="popbox hide prd-load"><span class="icon-loading"></span><i>Đang tải...</i></div>
    <div class="prd-container clearfix">
        <?php if($product): foreach ($product as $p): ?>
        <section class="prd-box">
            <div class="pb-hovbox">
                <a href="/product/detail/id/<?php echo $p->id ?>" class="pb-thumb">
                    <img src="<?php echo Yii::app()->baseUrl . $p->thumbnail ?>" alt="<?php echo $p->title ?>">
                </a>
                <div class="pb-mask">
                    <a href="/product/detail/id/<?php echo $p->id ?>" class="circle-red"><i class="icon-search"></i></a>
                </div>
            </div>
            <div class="pb-caption ftr-list">
                <h2><a href="/product/detail/id/<?php echo $p->id ?>"><?php echo $p->title ?></a></h2>
                <p><?php echo $p->quote ?></p>
                <a href="javascript:void(0)" data-oe-prdid="<?php echo $p->productCategory->id ?>" class="pbc-cattag"><?php echo $p->productCategory->title; ?></a>
            </div>
        </section>
        <?php endforeach; endif; ?>
    </div><!-- /.product-container -->
    <div class="clear"></div>
</section><!-- /.main-content -->